package com.vishnu.action;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.validator.BeanValidatorForm;
import org.apache.struts.validator.DynaValidatorForm;

public class BMSAction extends Action  {

	public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
		
		System.out.println("entered into actionforward.....");
		ActionForward af=null;
		af=mapping.findForward("success");
/*		ActionErrors aes=new ActionErrors();
          String name=request.getParameter("name");
          System.out.println("name:"+name);
          
          String pwd=request.getParameter("password");
          System.out.println("pwd:"+pwd);
          System.out.println("-------------------------------------------");
          System.out.println("ERROR key:"+request.getAttribute("org.apache.struts.action.ERROR"));
  		Enumeration enu=request.getAttributeNames();
  		while(enu.hasMoreElements()){
  		System.out.println((String)enu.nextElement());	
  		}
  		
  		 System.out.println("-------------------------------------------first over"); 
          
          
          
          
		if(name!="" && pwd!=""){
			  af=mapping.findForward("success");
		}else{
			if(name==""){
				aes.add("nameerr",new ActionMessage("nameerr"));
			}
			if(pwd==""){
				aes.add("pwderr",new ActionMessage("pwderr"));
			}
			saveErrors(request,aes);
			System.out.println("aes:"+aes);
			System.out.println("aes:"+aes.size());
			System.out.println("aes is empty:"+aes.isEmpty());
			af=mapping.findForward("failure");
		}
		System.out.println("-------------------------------------------");
		System.out.println("ERROR key:"+request.getAttribute("org.apache.struts.action.ERROR"));
		Enumeration enu2=request.getAttributeNames();
		while(enu2.hasMoreElements()){
		System.out.println((String)enu2.nextElement());	
		}
		System.out.println("-------------------------------------------second over");
		*/
		return af;
	}
}
